package com.cuit.mapper;

import com.cuit.entity.Voice;
import org.apache.ibatis.annotations.*;

import java.awt.print.Pageable;
import java.util.List;

@Mapper
public interface VoiceMapper{


    // 查询所有语音记录
    @Select({
            "<script>",
            "select id, text, file_name as fileName, file_path as filePath, create_time as createTime from voice",
            "<where>",
            "   <if test='keyword != null and keyword != \"\"'>",
            "       text LIKE CONCAT('%', #{keyword}, '%')",
            "   </if>",
            "</where>",
            "</script>"
    })
    List<Voice> selectByKeyword(@Param("keyword") String keyword);

    // 更新语音记录（这里只更新 text 字段，可根据需要扩展其他字段）
    @Update("UPDATE voice SET text = #{text} WHERE id = #{id}")
    int updateText(@Param("id") int id , String text);

    // 删除语音记录
    @Delete("DELETE FROM voice WHERE id = #{id}")
    int deleteVoice(@Param("id") int id);

    // 插入语音记录
    @Insert("INSERT INTO voice ( text, file_name, file_path, create_time) " +
            "VALUES ( #{text}, #{fileName}, #{filePath}, #{createTime})")
    int insert(Voice voice);


}
